package com.chushouya.manager.service.common.impl;

import com.general.framework.core.exception.Ex;
import com.chushouya.manager.dao.entity.PartnerEntity;
import com.chushouya.manager.dao.repository.PartnerRepository;
import com.chushouya.manager.service.common.PartnerApiService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class PartnerApiServiceImpl implements PartnerApiService {


    @Resource
    private PartnerRepository partnerRepository;

    @Override
    public PartnerEntity getPartnerInfo(Long partnerId) {
        PartnerEntity partnerEntity = partnerRepository.selectByPrimaryKey(partnerId);
        if(Objects.isNull(partnerEntity)) {
            throw Ex.business("合作商不存在");
        }
        return partnerEntity;
    }

    @Override
    public PartnerEntity getCachePartnerInfo(Long partnerId) {

        return this.getPartnerInfo(partnerId);
    }
}
